rm(list = ls())

set.seed(1917)

# load relevant packages
source("00_pckgs.R")

# at times, the r session may crash for reasons unrelated to this code.
# in an initial run, the variable crash_check should be set equal to 'pre' so that raw data is downloaded.
# ideally, the entire code should then run through without interruption.
# in possible post-crash runs, the crash_check can be set to anything else than 'pre', so that the data download step is skipped and model estimation picks up where it ended beforehand.
crash_check <- "pre"

# get raw input data
if (crash_check == "pre"){
  source("01_ep_get_data.R")
}

# run separable models
for (i in 1:2){

  toggle_nonsep <- 0
  source("02_ep_run_models.R")
}

# run non-separable models
for (i in 1:2){

  toggle_nonsep <- 1
  source("02_ep_run_models.R")
}

# extract results
source("03_ep_extract_results.R")

# visualize results
source("04_ep_viz.R")
